package com.he.hsdyc.common.log;/*
package he.hsdyc.demo.log;

import com.alibaba.druid.support.json.JSONUtils;
import he.hsdyc.demo.msg.Message;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

@Aspect
@Component
public class ParameterAop {

    private static Logger logger = LoggerFactory.getLogger(ParameterAop.class);

    private HttpServletRequest getRequest() {
        return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
    }


    @Pointcut("@annotation(org.springframework.web.bind.annotation.RequestMapping)" +
            "||@annotation(org.springframework.web.bind.annotation.GetMapping)" +
            "||@annotation(org.springframework.web.bind.annotation.PostMapping)" +
            "||@annotation(org.springframework.web.bind.annotation.PutMapping)" +
            "||@annotation(org.springframework.web.bind.annotation.PatchMapping)||@annotation(org.springframework.web.bind.annotation.DeleteMapping)")
    public void webAction() {}



    @Around(value = "webAction()")
    public Object around(JoinPoint joinPoint) throws Throwable {
        HttpServletRequest request = getRequest();
        //        操作记录日志
        Signature signature = joinPoint.getSignature();
        //Rest Class Name
        String restClassName = joinPoint.getTarget().getClass().getName();
        //请求方法名称
        String methodName = signature.getName();

        //方法入参
        */
/*Object[] args = joinPoint.getArgs();
        String params = "";
        try {
            for(Object o : args) {
                if(o instanceof ServletRequest) {
                    params +="request;";
                    continue;
                }
                if(o instanceof ServletResponse) {
                    params +="response;";
                    continue;
                }
                if(o instanceof BaseVO) {
                    params +=((BaseVO)o).toString()+";";
                    continue;
                }
                params += JSONUtils.toJSONString(o)+";";
            }
            if(params.indexOf( "," )>=0) params = params.substring( 0 , params.length( )-1 );
        }catch (Exception e) {
            e.printStackTrace();
            logger.info("解析参数错误:{}",e.getMessage());
        }*//*



        //记录当前时间
        Long curTime = System.currentTimeMillis();
        String result = "成功";
        try {
            //Thread.sleep(1000);
            return ((ProceedingJoinPoint)joinPoint).proceed();
        }catch (Exception v) {
            result="失败";
            logger.error("参数异常:{}",v.getMessage());
            return new Message(1601,v.getMessage());
        }*/
/*catch (Exception s) {
            result="失败";
            logger.error("业务异常:{}",s.getMessage());
            return new Message(1603,s.getMessage());
        }catch (Exception a) {
            result="失败";
            logger.error("认证异常:{}",a.getMessage());
            return new Message(1606,a.getMessage());
        }catch (Exception u) {
            result="失败";
            logger.error("该角色无此操作权限");
            return new Message(1606,u.getMessage());

        }catch (IOException io) {
            result = "失败";
            logger.error("导入导出，格式有误，请确定好格式再导入");
            io.printStackTrace();
            return new Message(1606,"导入导出，格式有误，请确定好格式再导入");
        }catch (RuntimeException r) {
            result="失败";
            r.printStackTrace();
            logger.error("运行时异常:{}",r.getMessage());
            return new Message(1606,"系统繁忙，请稍后重试");
        }catch (Exception e) {
            result="失败";
            e.printStackTrace();
            logger.error("系统异常:{}",e.getMessage());
            return new Message(1604,"系统繁忙，请稍后重试");
        }*//*
finally {
            //SysUser sysUser = getUser();
            logger.info("响应结果："+ result);
            logger.info("响应时间："+ (System.currentTimeMillis() - curTime)+"ms");

            //logger.info("操作人:{}, 请求:{}.{} {}, 响应时间: {}ms, 请求方式:{},方法参数: {}", null, restClassName, methodName,result, System.currentTimeMillis() - curTime,request.getMethod(),params);

        }


    }
}
*/
